package com.mail.io;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class SharedByteArrayInputStream extends ByteArrayInputStream implements
		SharedInputStream {
	protected int start = 0;

	public SharedByteArrayInputStream(byte[] paramArrayOfByte) {
		super(paramArrayOfByte);
	}

	public SharedByteArrayInputStream(byte[] paramArrayOfByte, int paramInt1,
			int paramInt2) {
		super(paramArrayOfByte, paramInt1, paramInt2);
		this.start = paramInt1;
	}

	public long getPosition() {
		return (this.pos - this.start);
	}

	public InputStream newStream(long paramLong1, long paramLong2) {
		if (paramLong1 < 0L)
			throw new IllegalArgumentException("start < 0");
		if (paramLong2 == -1L)
			paramLong2 = this.count - this.start;
		return new SharedByteArrayInputStream(this.buf, this.start
				+ (int) paramLong1, (int) (paramLong2 - paramLong1));
	}
}